/**
 * VUEshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.vueshop.com.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: 沈小白 2020-07-22 $
 */<template> 

	<view class="container">
		<view class="withdrawal-box">
			<view class="withdrawal-item pay title">编号</view>
			<view class="withdrawal-item time title">申请日期</view>
			<view class="withdrawal-item price title">金额</view>
			<view class="withdrawal-item status title">状态</view>
		</view>
		<block v-for="(item,index) in withdrawalsList" :key="index">
			<view class="point-box">
				<view class="point-item cont">{{item.id}}</view>
				<view class="point-item time">{{item.create_time}}</view>
				<view class="point-item price">{{filter(item.money)}}</view>
				<view class="point-item status"> 
				    {{item.status==-2?'无效作废':''}}
				    {{item.status==-1?'审核失败':''}}
				    {{item.status==0?'申请中':''}}
				    {{item.status==1?'审核通过':''}}
				    {{item.status==2?'提现完成':''}}
				    {{item.status==3?'转款失败':''}}
				</view>
			</view>
			
		</block>
		
	</view>

</template>

<script>
	import common from "@/common/common.js";
	import {getWithdrawals} from "@/api/api.js";
	export default {
		data() {
			return {
				loginInfo:"",
				withdrawalsList:"",
				params:{
					type:0,//0 个人余额 1团队提现
					size:10
				},
				type:0,// 0个人提现  1分销团队提现
				total:"",
			};
		},
		onLoad(option){
			/*type存在 分销团队提现  type=0  个人提现
			optian 存在 上级路由是团对佣金
			*/
			if(option&&option.type){ 
				this.params.type=1;
				this.type=option.type;
			}
			
		},
		onShow(){
			let loginInfo=uni.getStorageSync('loginInfo') || null;
			this.loginInfo=loginInfo;
			console.log(this.type)
			if(this.loginInfo!=null){
				this.getWithdrawals(this.params)
			}else{
				common.toast("none","请登录",2000)
			}
		},
		methods:{
			/*提现记录*/ 
			getWithdrawals(params){
				getWithdrawals(params).then(res=>{
					console.log(res)
					res.records.forEach((i,index)=>{
						console.log(i)
						var time=common.format(i.create_time,'yyyy-MM-dd ')
						i.create_time=time
					})
					this.withdrawalsList=res.records;
					this.total=res.total;
				})
			},
			onReachBottom(){//下拉加载数据
				
				if(this.withdrawalsList.length===this.total){
					common.toast("none","加载完了",2000)
					 return false;
				}
				this.params.size+=9;
				if(this.loginInfo!=null){
					this.getWithdrawals(this.params)
				}
				
				
			},
			/*保留两位小数*/
			filter(e) {
				let num = parseFloat(e).toFixed(2)
				return num;
			},
		}
	}
</script>

<style lang="scss">
	page{
	    background-color: #f5f5f5;
	}
	.container{
	    padding: 20rpx 20rpx;
	}
	.withdrawal-box{
	    background: #F0F0F0;
	    font-size: 26rpx;
	    color: #666666;
	    width: 100%;
	    padding: 20rpx 0;
	    border-radius: 10rpx;
	}
	.withdrawal-item{
	    display: inline-block; 
	    width: 25%;
	    word-break: keep-all;
	    white-space: nowrap;
	    overflow: hidden;
	    text-overflow: ellipsis;
	    text-align: center;
	    color: #666;
	}
	/* .withdrawal-box .pay{
	    width: 20%;
	}
	.withdrawal-box .time{
	    width: 27%;
	}
	.withdrawal-box .price{
	    width: 28%;
	}
	.withdrawal-box .status{
	    width: 25%;
	    color: #ff3b3b;
	} */
	/* .withdrawal-box .title{
	    color: #666666;
	    font-size: 32rpx;
	} */
	.point-box{
	    width: 100%;
	    font-size: 28rpx;
	    padding: 20rpx 0;
	    border-radius: 10rpx;
	    /* padding-left: 5rpx; */
	}
	.point-box:nth-child(odd){
	    background: #fff;
	}
	.point-box:nth-child(even){
	    background: #FAFAFA;
	}
	.point-item{
	    display: inline-block; 
	    width: 25%;
	    word-break: keep-all;
	    white-space: nowrap;
	    overflow: hidden;
	    text-overflow: ellipsis;
	    text-align: center;
	    color: #666;
	}
	.point-box .cont{
	    color: #808080;
	}
	.point-box .price{
	    color: #ff3b3b; 
	    text-align: center;
	}
	.point-box .time{
	    color: #808080;
	}
	.point-box .status{
	    color:  #808080;
	}
	.point-box .title{
	    text-align: center;
	}
</style>
